package com.cg.dto;


public enum ResultEnum {

    SUCCESS("0", "成功"),
    FAIL("1", "失败"),
    COMMON_EXCEPTION("5", "系统异常"),

    FAIL_PARAM("1001", "请求参数错误"),
    FAIL_LOGIN("1002", "登录失败"),

    FAIL_ACCOUNT_EXIST("1004", "账号已存在"),
    FAIL_ACCOUNT_NOT_EXIST("1005", "账号不存在"),
    FILE_NOT_LOGIN("2001", "未登录"),
    FILE_NOT_HAVE_PERMISSION("2002", "没有权限"),
    FAIL_ACCOUNT_LOCK("2003", "账号已被锁定"),

    FAIL_HAVE_NOT_EXIST("3005", "数据不存在"),
    FAIL_PHONE_EXIST("3006", "已经发送过短信验证码，请勿重新发送"),
    FAIL_PHONE_ACCOUNT("3007", "还手机号已注册"),
    FAIL_SMS_SEND("3008", "短信发送失败"),
    PHONE_CODE_ERROR("3009", "验证码不正确"),
    PHONE_CODE_NULL("3009", "请输入验证码"),
    PATIENT_USER_CREATE_ERROR("3010", "注册失败"),
    TYPE_CODE_ERROR("3011", "TypeCode不存在"),
    FAIL_PHONE_NO_ACCOUNT("3012", "该用户还未注册"),
    LOGIN_PASSWORD_ERROR("3013", "用户密码错误"),
    LOGIN_PATIENT_ERROR("3013", "用户没有就诊信息"),
    UPDATE_PASSWORD_ERROR("3014", "新密码和旧密码不能一致"),
    UPDATE_PASSWORD_NULL("3015", "旧密码不能为空"),
    UPDATE_PASSWORD_NEW_NULL("3016", "新密码不能为空"),
    TOKEN_PATIENT_NULL("3017", "该用户没有就诊记录"),
    TOKEN_INFO_NULL("3018", "认证失败"),
    ORDER_EXIST("3019", "当天之内，同一时段，同一患者是已有预约"),
    ORDER_COUNT_ERROR("3020", "当天之内，同一患者预约的次数，不能超过3次"),
    FAIL_ORDER("3021", "预约失败，没有余号"),
    ;




    String code;
    String msg;

    ResultEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }


    public static ResultEnum getByCode(String code) {
        if (code == null) {
            return COMMON_EXCEPTION;
        }
        for (ResultEnum outputEnum : ResultEnum.values()) {
            if (code.equals(outputEnum.code)) {
                return outputEnum;
            }
        }
        return COMMON_EXCEPTION;
    }
}
